package com.yitiao.controller;

import com.yitiao.service.ClientDiscoveryService;
import lombok.AllArgsConstructor;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/discovery")
@AllArgsConstructor
public class ClientDiscoveryController {

    private final ClientDiscoveryService discoveryService;

    @GetMapping("/instance")
    public List<ServiceInstance> getInstance(@RequestParam(defaultValue = "cloud-alibaba-nacos") String serviceId) throws Exception {
       return discoveryService.getInstance(serviceId);
    }
}
